if(NOT CPUNCHLINE_BUILD_THIRDPARTY)
    find_package(nng REQUIRED)
    if(TARGET nng::nng AND NOT TARGET nng)
        add_library(nng ALIAS nng::nng)
    endif()
endif()

set(NNG_TEST_BUS_SRC nng_bus_test.c)
set(NNG_TEST_PAIR_SRC nng_pair_test.c)
set(NNG_TEST_PAIR_ASYNC_MANAGER_SRC nng_pair_async_manager_test.cpp)
set(NNG_TEST_PAIR_ASYNC_ADAPTER_SRC nng_pair_async_adapter_test.cpp)
set(NNG_TEST_PIPELINE_SRC nng_pipeline_test.c)
set(NNG_TEST_PUBSUB_SRC nng_pubsub_test.c)
set(NNG_TEST_REQRESP_SRC nng_reqresp_test.c)
set(NNG_TEST_SURVERY_SRC nng_survey_test.c)

add_executable(nng_bus_test ${NNG_TEST_BUS_SRC})
target_link_libraries(nng_bus_test PRIVATE Threads::Threads nng)

add_executable(nng_pair_test ${NNG_TEST_PAIR_SRC})
target_link_libraries(nng_pair_test PRIVATE Threads::Threads nng)

add_executable(nng_pair_async_manager_test ${NNG_TEST_PAIR_ASYNC_MANAGER_SRC})
target_link_libraries(nng_pair_async_manager_test PRIVATE Threads::Threads nng)

add_executable(nng_pair_async_adapter_test ${NNG_TEST_PAIR_ASYNC_ADAPTER_SRC})
target_link_libraries(nng_pair_async_adapter_test PRIVATE Threads::Threads nng)

add_executable(nng_pipeline_test ${NNG_TEST_PIPELINE_SRC})
target_link_libraries(nng_pipeline_test PRIVATE Threads::Threads nng)

add_executable(nng_pubsub_test ${NNG_TEST_PUBSUB_SRC})
target_link_libraries(nng_pubsub_test PRIVATE Threads::Threads nng)

add_executable(nng_reqresp_test ${NNG_TEST_REQRESP_SRC})
target_link_libraries(nng_reqresp_test PRIVATE Threads::Threads nng)

add_executable(nng_survey_test ${NNG_TEST_SURVERY_SRC})
target_link_libraries(nng_survey_test PRIVATE Threads::Threads nng)

install(TARGETS nng_bus_test nng_pair_test nng_pipeline_test nng_pubsub_test nng_reqresp_test nng_survey_test nng_pair_async_adapter_test nng_pair_async_manager_test DESTINATION test)
